package edu.gdin.ecommerce.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import edu.gdin.ecommerce.util.DateUtil;
import edu.gdin.ecommerce.util.DicConverter;

/**
 * CardBatch entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_card_batch", catalog = "ecommerce")
public class CardBatch implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 455680001660177028L;
	private String batchNo;
	private Integer num;
	private Integer status;
	private String applicant;
//	private Integer cardIssuerId;
	private Integer materialType;
	private String sectionBegin;
	private String sectionEnd;
	private Date createTime;
	private Date updateTime;
	private String modifier;
	private String batchDesc;
	private CardIssuer cardIssuer;

	// Constructors

	/** default constructor */
	public CardBatch() {
	}

	/** full constructor */
	public CardBatch(String batchNo, Integer num, Integer status,
			String applicant, Integer materialType, String sectionBegin,
			String sectionEnd, Date createTime, Date updateTime,
			String modifier, String batchDesc, CardIssuer cardIssuer) {
		super();
		this.batchNo = batchNo;
		this.num = num;
		this.status = status;
		this.applicant = applicant;
		this.materialType = materialType;
		this.sectionBegin = sectionBegin;
		this.sectionEnd = sectionEnd;
		this.createTime = createTime;
		this.updateTime = updateTime;
		this.modifier = modifier;
		this.batchDesc = batchDesc;
		this.cardIssuer = cardIssuer;
	}

	// Property accessors
	@Id
	@Column(name = "BATCH_NO", unique = true, nullable = false, length = 20)
	public String getBatchNo() {
		return this.batchNo;
	}

	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}

	@Column(name = "NUM", nullable = false)
	public Integer getNum() {
		return this.num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	@Column(name = "STATUS", nullable = false)
	public Integer getStatus() {
		return this.status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	@Column(name = "APPLICANT", nullable = false, length = 20)
	public String getApplicant() {
		return this.applicant;
	}

	public void setApplicant(String applicant) {
		this.applicant = applicant;
	}

//	@Column(name = "CARD_ISSUER_ID", nullable = false)
//	public Integer getCardIssuerId() {
//		return this.cardIssuerId;
//	}
//
//	public void setCardIssuerId(Integer cardIssuerId) {
//		this.cardIssuerId = cardIssuerId;
//	}

	@Column(name = "MATERIAL_TYPE", nullable = false)
	public Integer getMaterialType() {
		return this.materialType;
	}

	public void setMaterialType(Integer materialType) {
		this.materialType = materialType;
	}

	@Column(name = "SECTION_BEGIN", length = 20)
	public String getSectionBegin() {
		return this.sectionBegin;
	}

	public void setSectionBegin(String sectionBegin) {
		this.sectionBegin = sectionBegin;
	}

	@Column(name = "SECTION_END", length = 20)
	public String getSectionEnd() {
		return this.sectionEnd;
	}

	public void setSectionEnd(String sectionEnd) {
		this.sectionEnd = sectionEnd;
	}

	@Column(name = "CREATE_TIME", nullable = false, length = 19)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "UPDATE_TIME", length = 19)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "MODIFIER", length = 20)
	public String getModifier() {
		return this.modifier;
	}

	public void setModifier(String modifier) {
		this.modifier = modifier;
	}

	@Column(name = "BATCH_DESC", length = 200)
	public String getBatchDesc() {
		return this.batchDesc;
	}

	public void setBatchDesc(String batchDesc) {
		this.batchDesc = batchDesc;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "CARD_ISSUER_ID", nullable = false)
	public CardIssuer getCardIssuer() {
		return cardIssuer;
	}

	public void setCardIssuer(CardIssuer cardIssuer) {
		this.cardIssuer = cardIssuer;
	}
	
	// -- property Converter --
	
	public String statusToString() {
		return DicConverter.dicMapConvert("DIC_CARD_BATCH_STATUS", this.getStatus());
	}
	
	
	public String materialTypeToString() {
		return DicConverter.dicMapConvert("DIC_CARD_MATERIAL_TYPE", this.getMaterialType());
	}

}